<%@page import="java.util.Collection"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="java.io.File"%>
<%@page import="org.apache.commons.fileupload.FileItem"%>
<%@page import="java.util.List"%>
<%@page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
<%@page import="org.apache.commons.fileupload.FileItemFactory"%>
<%@page import="sun.org.mozilla.javascript.internal.xml.XMLLib.Factory"%>
<%@page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<%@page import="org.apache.commons.fileupload.UploadContext"%>
<%@page import="com.sun.istack.internal.logging.Logger"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
*{
margin:0px;
padding:0px;
}
#image1{
      
	  background:url(image/1.jpg);
	  background-position:center;
	  background-size:cover;
	  filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(
      src='image/1.jpg',
      sizingMethod='scale');
	  width:1350px;
	  height:1000px;
	  z-index:-1;
	  background-repeat:no-repeat;
}
.center{/*这是控制中间的部分的样式表*/
     width:920px;
     height:1000px;
     top:10px;
     left:200px;
    
     position:absolute;
}
#image2{ 
		background:url(image/2.jpg);
		width:100%;
		top:50px;left:385px;
		height:356px;
		background-repeat:no-repeat;
		
}
/*下面是关于left部分的布局*/
#display{
top:320px;
width:920px;
height:644px;
background-color:white;
position:absolute;
}

/*下面是底部的布局*/
#bottom{
background:url(image/3.png);
width:1350px;
height:260px;
}
#remind{
     font: 25px/1.125;
     top: 240px;
     left:320px;
     position:absolute;
}
</style>
</head>
<body>
<%

  Map<String,String> paramMap= new HashMap();

    boolean isMultipart = ServletFileUpload.isMultipartContent(request);
    try{
      if(isMultipart){
    	FileItemFactory factory = new DiskFileItemFactory();
        ServletFileUpload upload = new ServletFileUpload(factory);
        List <FileItem> items = upload.parseRequest(request);
        for(FileItem item:items){
        	if(item.isFormField()){
        	    String fieldName = item.getFieldName(); 
        	    String value = item.getString("UTF-8");
        	    paramMap.put(fieldName, value); 
        	}else{
        		System.out.println(request.getRealPath("image"));
        		System.out.print(item.getName());
        		String fileName=item.getName();
        		File file = new File(request.getRealPath("image")+"/",fileName);
        		item.write(file);
        	    out.flush();
        	}
        }
        		
      }
        
    }catch(Exception e){
    	
    	e.printStackTrace();
    }
    request.setCharacterEncoding("utf-8");
    
    String loginName = paramMap.get("loginName");
   
    String password=paramMap.get("password");
    String nickName=paramMap.get("nickName");
    String realName=paramMap.get("realName");//user2
    String province= paramMap.get("province");
    String city = paramMap.get("city");
    String address = paramMap.get("district");
    String sex=paramMap.get("sex");
    String emotion=paramMap.get("emotion");
    String birthday=paramMap.get("birthday");
    String introduction=paramMap.get("introduction");
    String identify=paramMap.get("identify");
    String email=paramMap.get("email");
    Connection conn=null;
    PreparedStatement prepared=null;
    ResultSet set=null;
    String sql=null;
   
    try{
    	Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    	conn=java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/school1130", "root", "root");
    	prepared=conn.prepareStatement("update user1 set password=?,nickname=?,identify=?where account=?");
    	prepared.setString(1, password);
        prepared.setString(2, nickName);
    	prepared.setString(3,identify );
    	prepared.setString(4,loginName);
    	prepared.executeUpdate(); 
    	prepared=conn.prepareStatement("update user2 set name=?,province=?,city=?,address=?,sex=?,emotion=?,introduction=?,email=?,birthday=?where account=?");
    	prepared.setString(1, realName);
    	prepared.setString(2, province);
    	prepared.setString(3, city);
    	prepared.setString(4, address);
    	prepared.setString(5, sex);
    	prepared.setString(6, emotion);
    	prepared.setString(7, introduction);
    	prepared.setString(8, email);
    	prepared.setString(9,birthday);
    	prepared.setString(10, loginName);
    	prepared.executeUpdate();
    }catch(Exception e){
    	e.printStackTrace();
    }finally{
    	
    	prepared.close();
    	conn.close();
    	 
    }
    
%>

<div id="image1">
		<div class="center">
			<div id="image2">
			</div>
			 <div id="display">
			 <div style="top:100px;position:absolute;left:30px;" ><font style="weight-size:80px;font-size:35px; color:red">恭喜你修改成功了！</font></div>	
			 <div id="remind">
			    <div><img src="image/success.jpg"/><a href="homepage2.jsp">点此返回》》》》</a>
			 	</div>
			 </div>
		</div>
</div>
</div>
</div>
<div id="bottom"> </div>
</body>
</html>